using System;

namespace SharpMud.MudLib.SAMPLE.Entities.Filtration
{
	public class FilterOperands
	{
		public class OR : CompoundFilter
		{
			private ICharacterFilter[] _Filters;
			public OR(params ICharacterFilter[] filters)
			{
			}

			public override ICharacterFilter[] Filters
			{
				get
				{
					return _Filters;
				}
			}

			protected override bool DoesCharacterPass(ICharacter character)
			{
				foreach(ICharacterFilter cf in Filters)
				{
					if(cf.DoesCharacterPass(character))
						return true;
				}
				return false;
			}
		}


		public class AND : CompoundFilter
		{
			private ICharacterFilter[] _Filters;
			public AND(params ICharacterFilter[] filters)
			{
			}

			public override ICharacterFilter[] Filters
			{
				get
				{
					return _Filters;
				}
			}

			protected override bool DoesCharacterPass(ICharacter character)
			{
				bool b = true;
				foreach(ICharacterFilter cf in Filters)
				{
					b = b & cf.DoesCharacterPass(character);
					if(b==false)
						return false;
				}
				return true;
			}
		}
		

		public class XOR : CompoundFilter
		{
			private ICharacterFilter[] _Filters;
			public XOR(params ICharacterFilter[] filters)
			{
			}

			public override ICharacterFilter[] Filters
			{
				get
				{
					return _Filters;
				}
			}

			protected override bool DoesCharacterPass(ICharacter character)
			{
				bool b = false;
				foreach(ICharacterFilter cf in Filters)
				{
					if(cf.DoesCharacterPass(character))
					{
						if(b==true)
							return false;
						if(b==false)
							b = true;
					}
				}
				return b;
			}
		}
	}
}
